package com.wanglibao.woodtrade.woodtrade.util;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.text.TextUtils;

public class CallPhone {

	public static void call(String phoneNumber, Context activity) {
		// 调用系统的拨号服务实现电话拨打功能
		if (!TextUtils.isEmpty(phoneNumber)) {
			Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
			if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
				return;
			}
			activity.startActivity(intent);
		} else {
			ToastUtil.createNormalToast(activity, "电话号为空");
		}
	}

	public static void SendSMS(Context activity, String aContent, String phoneNumber) {
		Intent iIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phoneNumber));// 传入要发送的地址
		// 设置短信内容
		iIntent.putExtra("sms_body", aContent);// 设置传递的信息内容
		// 启动短信服务内容
		activity.startActivity(iIntent);
	}
}
